package com.ys.ylideas.util;

import com.alibaba.fastjson.JSONObject;

public class OtherJsonRequest {
	private JSONObject header;
	private JSONObject params;
	
	private JSONObject body;
	private JSONObject requestData;
	private JSONObject totalJson;
	
	private static String token = "de86e485832d365067078dda4cd2d2eb";
	
	public void init(){
		header = new JSONObject();
		params = new JSONObject();
		
		body = new JSONObject();
		requestData = new JSONObject();
		totalJson = new JSONObject();
				
	}
	
	public String getAccountInfo(String access_token){
		init();
		
		params.put("token", token);
		params.put("accessToken", access_token);
		header.put("header", params);
		
		String[] accountFields = {
				"userId",
				"regDomain"
		};
		requestData.put("accountFields", accountFields);
		body.put("body", requestData);
		
		totalJson.putAll(header);
		totalJson.putAll(body);
		
		
		return totalJson.toString();
	}
	
	public String getCampaign(String access_token){
		init();

		params.put("token", token);
		params.put("accessToken", access_token);
		header.put("header", params);
		
		String[] campaignFields = {
				"campaignName"
		};
		
		requestData.put("campaignFields", campaignFields);
		requestData.put("campaignIds", null);
		
		body.put("body", requestData);
		
		totalJson.putAll(header);
		totalJson.putAll(body);
		
		return totalJson.toString();
	}
	
	public String getAdgroup(String access_token,Long[] ids){
		init();

		params.put("token", token);
		params.put("accessToken", access_token);
		header.put("header", params);
		
		String[] adgroupFields = {
			"adgroupName"	
		};
		
		requestData.put("adgroupFields", adgroupFields);
		requestData.put("idType", 3);
		requestData.put("ids", ids);
		
		body.put("body", requestData);
		
		totalJson.putAll(header);
		totalJson.putAll(body);
		
		return totalJson.toString();
	}
	
	public String getWord(String access_token,Long[] ids){
		init();

		params.put("token", token);
		params.put("accessToken", access_token);
		header.put("header", params);
		
		String[] wordFields = {
				"status"
		};
		
		requestData.put("wordFields", wordFields);
		requestData.put("ids", ids);
		requestData.put("idType", 5);
		
		body.put("body", requestData);
		totalJson.putAll(header);
		totalJson.putAll(body);
		
		return totalJson.toString();		
		
	}
}
